<html>
<head>
	<style>
		@import "../robot/robot.css";
	</style>
	<script src="../../../dojo/dojo.js" data-dojo-config="isDebug: true, async: true"></script>
	<script>
		require(["doh/runner", "doh/robot", "dojo/domReady!"], function(doh, robot){
			var textbox = document.getElementById('textbox');
			var BACKSPACE = 8;
			var END = 35;
			var LEFT_ARROW = 37;
			var SHIFT = 16;

			doh.register("robot", [
				{
					name: "dojorobot1",
					timeout: 6900,
					setUp: function(){
						textbox.value="hi";
					},
					runTest: function(){
						var d = new doh.Deferred();
						robot.mouseMove(30, 30, 500);
						robot.mouseClick({left: true}, 500);
						robot.typeKeys(" again", 500, 2500);
						robot.sequence(d.getTestCallback(function(){
							doh.is("hi again", document.getElementById('textbox').value);
						}), 900);
						return d;
					}
				},
				{
					name: "shiftarrow",
					timeout: 10000,
					setUp: function(){
						textbox.value="hi again";
					},
					runTest: function(){
						var d = new doh.Deferred();
						robot.keyPress(END,500);
						// test shift+arrow with keyPress
						for(var i=0; i<3; i++){
							robot.keyPress(LEFT_ARROW, 500, {shift: true});
						}
						// test shift+arrow with keyDown then keyUp
						robot.keyDown(SHIFT,500);
						for(var i=0; i<3; i++){
							robot.keyDown(LEFT_ARROW,500);
							robot.keyUp(LEFT_ARROW,20);
						}
						robot.keyUp(SHIFT,500);
						robot.keyPress(BACKSPACE,500);
						robot.sequence(d.getTestCallback(function(){
							doh.is("hi", textbox.value);
						}), 900);
						return d;
					}
				}
			]);
			doh.run();
		});
	</script>
</head>
<body>
	<form>
	<input type="text" value="hi" id="textbox" style="position:absolute; left:0px; top:20px; font-family:system;"></input>
	</form>
</body>
</html>
